Vue.component("app",{
    template:`
<div>
    <div id="header" class="wrap">
        <img src="images/logo.gif" />
    </div>
    <div id="navbar" class="wrap">
        <div class="profile">
            <span v-if="user">
                您好，{{user.uname}}
                <a href="logout">退出</a> 
            </span>
            <span v-else><a href="login.html">登录</a></span>
            <span class="return"><a href="manage.html">返回列表</a></span>
            <span class="addnew"><a href="add.html">添加新投票</a></span>
        </div>
        <div class="search">
            <form method="post" action="#">
                <input type="text" name="keywords" class="input-text" value=""/><input type="submit" name="submit" class="input-button" value="" />
            </form>
        </div>
    </div>
    <slot></slot>
    <div id="footer" class="wrap">
        源辰信息 &copy; 版权所有
    </div>
</div>
    `,
    data() {
       return {user:null}
    },
    created(){
        // 获取当前用户信息
        axios.get("myinfo").then(res=>{
            this.user = res.data.data;
        });
    }
})